package com.github.easyms.common.vo;

import com.github.easyms.common.constant.EasymsServiceStatus;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;

/**
 * 统一错误返回
 *
 * @author Leo.Liao
 * @date 2020-05-01 15:14:51
 */
@Data
@ToString
@NoArgsConstructor
@ApiModel
public class ErrorVo implements Serializable {

    private static final long serialVersionUID = 5966796314160255424L;

    @ApiModelProperty(value = "业务错误代码",example = "40019")
    private Integer code;

    @ApiModelProperty(value = "业务错误提示信息",example = "账号不存在")
    private String message;

    public static ErrorVo ERR(){
        return new ErrorVo(EasymsServiceStatus.ERROR);
    }

    public static ErrorVo ERR(Integer code , String message){
        return new ErrorVo(code,message);
    }

    public ErrorVo(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public ErrorVo(EasymsServiceStatus easymsServiceStatus) {
        this.code = easymsServiceStatus.code();
        this.message = easymsServiceStatus.getMsgCode();
    }

}
